import { mapState, mapGetters, mapMutations, mapActions } from 'vuex';

export default {
  name: 'Home',
  data() {
    return {
      msg: 'This is home page.'
    }
  },
  computed: {
    ...mapState(['count']),
    ...mapGetters(['getCount']),
  },
  methods: {
    ...mapMutations(['syncIncrement']),
    // 同步增加
    handleSyncIncrement() {
      this.syncIncrement(1);
    },
    ...mapActions(['asyncIncrement']),
    // 异步增加
    handleAsyncIncrement() {
      this.$store.dispatch('asyncIncrement', 2);
    },
  },
  mounted() {
    console.log(this.count);
  }
}